from BeautifulSoup import BeautifulSoup as bs

def parse_mangas(data):
    soup = bs(data)
    rows = soup('td')
    rows = [rows[y] for y in range(1, len(rows), 3) if rows[y].a]
    text = [row.a.string.encode('utf-8') for row in rows]
    urls = [row.a['href'].encode('utf-8') for row in rows]
    return text, urls
    
def parse_chapters(data):
    soup = bs(data)
    rows = soup('td')
    rows = [rows[y] for y in range(0, len(rows), 3) if rows[y].a]
    text = [row.a.string.encode('utf-8') for row in rows]
    urls = [row.a['href'].encode('utf-8') for row in rows]
    return text, urls

def parse_pages(data):
    soup = bs(data)
    options = soup('option')
    options = [option.string.encode('utf-8') for option in options[1:]]
    urls = options

    return options, urls

def parse_images_url(data, page):
    soup = bs(data)
    images_url = soup.findAll('img', {'class':"manga-page"})

    return images_url[0]['src']

name = "OneManga"
url = "http://www.onemanga.com"
mangas_url = "/directory/"
mangas_url_ext = "?s=r"